/**
 * 2. 调节方式-调度约束
 */
Ext.define('Admin.view.waterOptimum.submodule.schedulingConstraints',{
	extend:'Ext.grid.Panel',
	xtype:'woSchedulingConstraints',
	//起别名
	alias:'woSchedulingConstraints',
	require:[],
	user:[],
	userCLs:'big-100 small-100',
	border: true,
	store: {xtype: 'store'},
	padding: '0 10 10 10',
	columns: [
		{ text: '时间', dataIndex: 'index1', width:'11.5%', minWidth: 100, align: 'center' },
		{text: '水库', width: '44%', minWidth: 720, columns:[{ text: '最高水位(m)', dataIndex: 'index2', minWidth: 120, width:'16%', align: 'center', formatter: 'round(3)' },
			{ text: '最低水位(m)', dataIndex: 'index3', minWidth: 120, width:'16%', align: 'center', formatter: 'round(3)' },
			{ text: '最大下泄(m³/s)', dataIndex: 'index4', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)' },
			{ text: '最小下泄(m³/s)', dataIndex: 'index5', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)' },
			{ text: '最大出力(kW)', dataIndex: 'index6', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)' },
			{ text: '最小出力(kW)', dataIndex: 'index7', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)' }]}
	],
    plugins: [{
        ptype: 'cellediting',
        clicksToEdit: 1
    }],
	displayData: function(data){
		var dams = data.index1;
		var head = new Array();
		head.push({
			text: '时间', dataIndex: 'index1', width:'11.5%', minWidth: 100, align: 'center'
		});
		for(var i=0;i<dams.length;i++){
			head.push({ text: dams[i], text: dams[i], width: '44%', minWidth: 720, columns:[
				{ text: '最高水位(m)', dataIndex: 'index'+(i+1)+'_1', minWidth: 120, width:'16%', align: 'center', formatter: 'round(3)',
		            editor: {
		                xtype: 'textfield',
		                allowBlank: false
		            } },
				{ text: '最低水位(m)', dataIndex: 'index'+(i+1)+'_2', minWidth: 120, width:'16%', align: 'center', formatter: 'round(3)',
		            editor: {
		                xtype: 'textfield',
		                allowBlank: false
		            } },
				{ text: '最大下泄(m³/s)', dataIndex: 'index'+(i+1)+'_3', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)',
		            editor: {
		                xtype: 'textfield',
		                allowBlank: false
		            } },
				{ text: '最小下泄(m³/s)', dataIndex: 'index'+(i+1)+'_4', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)',
		            editor: {
		                xtype: 'textfield',
		                allowBlank: false
		            } },
				{ text: '最大出力(kW)', dataIndex: 'index'+(i+1)+'_5', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)',
		            editor: {
		                xtype: 'textfield',
		                allowBlank: false
		            } },
				{ text: '最小出力(kW)', dataIndex: 'index'+(i+1)+'_6', minWidth: 120, width:'17%', align: 'center', formatter: 'round(3)',
		            editor: {
		                xtype: 'textfield',
		                allowBlank: false
		            } }
			] });
		}
		this.reconfigure(null, head);
		this.getStore().setData(data.index2);
	},
	getGridData: function(){
		var data = this.getStore();
		var recordArr = [];
		for(var i=0;i<data.getCount();i++){
			recordArr.push(data.getAt(i).getData());
		}
		var jsonArr = Ext.encode(recordArr);
		return jsonArr;
	},
	getGridDataAll: function(){
		var output = '{';
		output += '"index1":'+this.getGridData();
		
		output += '}';
		return output;
	}
});